package com.dyh.scdemo.fprovider.controller;


import com.dyh.scdemo.fprovider.api.HelloApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
@Author=Joey Wheeler
@Date=2020/10/28 11:33
*/
//@RequestMapping("/hello")
@RestController
public class HelloController implements HelloApi {

    @Value("${server.port}")
    public String port;

    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public String hello(String msg) {
        return String.format("hello! msg=%s port=%s",msg,port) ;
    }

    @Override
    public String error() {
        throw new RuntimeException("error");
        //return "error";
    }

    @Override
    public String timeout(int n) {
        try {
            Thread.sleep(1000*n);
        } catch (InterruptedException e) {
            //e.printStackTrace();
            logger.error("e=",e);
        }
        return "timeout's res";
    }
}
